﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class RotationGear : MonoBehaviour {

    public float angle = 160f;
    public float delay = 0.5f;
    public float duration = 1.6f;
    public Ease ease = Ease.InOutSine;

	// Use this for initialization
    IEnumerator Start () {
        yield return new WaitForSeconds(delay);
        var from = transform.localRotation.z + angle / 2f;
        var to = transform.localRotation.z - angle / 2f;
        transform.rotation = Quaternion.Euler(0, 0, from);
        transform.DOLocalRotateQuaternion(Quaternion.Euler(0, 0, to), duration)
                 .SetLoops(-1, LoopType.Yoyo)
                 .SetEase(ease)
                 .PlayForward();
	}

}
